<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* 
      首先，我们需要确定题目中的所有示例都是能跳到最后的
      */
      var jump = function (nums) {
        if (nums.length <= 1) return 0
        let step = 0
        let cover = 0 //当前可走的范围
        let next = 0
        for (let i = 0; i < nums.length; i++) {
          next = Math.max(next, i + nums[i])
          if (i == cover) {
            step++
            cover = next
            if (next >= nums.length - 1) break
          }
        }
        return step
      }
    </script>
  </body>
</html>
